package com.njth.beans;

import java.io.Serializable;
import java.lang.reflect.*;

public class BaseBean implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1204461079450709621L;
	
	private int id;
	
	
	
	public int getId() {
		return id;
	}



	public void setId(int id) {
		this.id = id;
	}



	public static String toString(Object obj){
	      if(obj==null)
	          return null;
	      if(obj instanceof String || obj instanceof StringBuffer || obj instanceof StringBuilder)
	          return obj.toString();
	      if(obj instanceof Number)
	          return obj.toString();
	      if(obj instanceof Boolean)
	          return obj.toString();
	      if(obj instanceof Character)
	          return obj.toString();
	      if(obj instanceof java.util.Date)
	          return obj.toString();
	      
	        Class cl = obj.getClass();
	      
	      String r = cl.getName();
	      // inspect the fields of this class and all superclasses
	      do
	      {
	         r += "[";
	         Field[] fields = cl.getDeclaredFields();
	         AccessibleObject.setAccessible(fields, true);
	         // get the names and values of all fields
	         for (Field f : fields)
	         {
	            if (!Modifier.isStatic(f.getModifiers()))
	            {
	               if (!r.endsWith("[")) r += ",";
	               r += f.getName() + "=";
	               try
	               {
	                  Object val = f.get(obj);
	                  r += toString(val);
	               }
	               catch (Exception e) { e.printStackTrace(); }
	            }
	         }
	         r += "]";
	         cl = cl.getSuperclass();
	      }
	      while (cl != Object.class);
	      return r;

	    }

}
